//
//  RefundPlanCell.m
//  JinFuThree
//
//  Created by 毛韶谦 on 2018/9/10.
//  Copyright © 2018年 毛韶谦. All rights reserved.
//

#import "RefundPlanCell.h"

@interface RefundPlanCell ()

@property (nonatomic, strong) UIImageView *leftImageView;
@property (nonatomic, strong) UILabel *periodsLabel;
@property (nonatomic, strong) UILabel *moneyLabel;
@property (nonatomic, strong) UILabel *dateLabel;
@property (nonatomic, strong) UILabel *stateLabel;

@end

@implementation RefundPlanCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self.leftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.contentView);
            make.left.mas_equalTo(self.contentView.mas_left).offset(20);
            make.size.mas_equalTo(CGSizeMake(20, 20));
            make.top.mas_equalTo(self.contentView.mas_top).offset(35);
            make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-35);
        }];
        [self.periodsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.leftImageView.mas_right).offset(20);
            make.top.mas_equalTo(self.contentView.mas_top).offset(20);
        }];
        [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.contentView.mas_right).offset(-20);
            make.top.mas_equalTo(self.contentView.mas_top).offset(20);
        }];
        [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.leftImageView.mas_right).offset(20);
            make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-20);
        }];
        [self.stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.contentView.mas_right).offset(-20);
            make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-20);
        }];
        
        [self.lineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView.mas_left).offset(20);
            make.right.mas_equalTo(self.contentView.mas_right).offset(-20);
            make.bottom.mas_equalTo(self.contentView.mas_bottom);
            make.height.mas_equalTo(0.5);
        }];
    }
    return self;
}



- (void)updateInfoCellWithModel:(NSIndexPath *)indexPath {
    
    self.leftImageView.image = [UIImage imageNamed:@"normal_jieDai"];
    self.periodsLabel.text = [NSString stringWithFormat:@"%ld/6期",indexPath.row];
    self.moneyLabel.text = @"833.33";
    self.dateLabel.text = @"还款日 20180809";
    self.stateLabel.text = @"待还款";
    if (indexPath.row == 0) {
        self.leftImageView.image = [UIImage imageNamed:@"checked_jieDai"];
    }
}


- (UIImageView *)lineImageView {
    
    if (!_lineImageView) {
        _lineImageView = [[UIImageView alloc] init];
        _lineImageView.backgroundColor = ThemeMaoLineColor;
        
        [self.contentView addSubview:_lineImageView];
    }
    return _lineImageView;
}

- (UIImageView *)leftImageView {
    
    if (!_leftImageView) {
        _leftImageView = [[UIImageView alloc] init];
        [_leftImageView setContentMode:UIViewContentModeScaleAspectFit];
        _leftImageView.layer.cornerRadius = 10;
        _leftImageView.layer.masksToBounds = YES;
        
        [self.contentView addSubview:_leftImageView];
    }
    return _leftImageView;
}

- (UILabel *)periodsLabel {
    
    if (!_periodsLabel) {
        _periodsLabel = [[UILabel alloc] init];
        _periodsLabel.textColor = HexColor(0x333333);
        _periodsLabel.font = [UIFont systemFontOfSize:15];
        
        [self.contentView addSubview:_periodsLabel];
    }
    return _periodsLabel;
}
- (UILabel *)moneyLabel {
    
    if (!_moneyLabel) {
        _moneyLabel = [[UILabel alloc] init];
        _moneyLabel.textColor = HexColor(0x333333);
        _moneyLabel.font = [UIFont boldSystemFontOfSize:15];
        
        [self.contentView addSubview:_moneyLabel];
    }
    return _moneyLabel;
}
- (UILabel *)dateLabel {
    
    if (!_dateLabel) {
        _dateLabel = [[UILabel alloc] init];
        _dateLabel.textColor = HexColor(0x333333);
        _dateLabel.font = [UIFont systemFontOfSize:13];
        
        [self.contentView addSubview:_dateLabel];
    }
    return _dateLabel;
}
- (UILabel *)stateLabel {
    
    if (!_stateLabel) {
        _stateLabel = [[UILabel alloc] init];
        _stateLabel.textColor = HexColor(0x333333);
        _stateLabel.font = [UIFont systemFontOfSize:13];
        
        [self.contentView addSubview:_stateLabel];
    }
    return _stateLabel;
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
